
local killed = achievements.GetValue( "Duckhunt", "total", 0 )

local flying = { "npc_crow", "npc_pigeon", "npc_seagull", "npc_cscanner", "npc_manhack", "npc_helicopter" }
local function PlayerKilledNPC( msg )
	local victim, inflictor, attacker = msg:ReadString(), msg:ReadString(), msg:ReadEntity()
	
	if ( killed != 200 && attacker == LocalPlayer() && inflictor == "weapon_shotgun" ) then
		if ( table.HasValue( flying, victim ) ) then
			killed = math.Clamp( killed + 1, 0, 200 )
			achievements.SetValue( "Duckhunt", "total", killed )
			achievements.Update( "Duckhunt", killed / 200, killed .. "/200" )
		end
	end		
	
	return victim, inflictor, attacker
end
usermessage.AddHook( "PlayerKilledNPC", "Achievements.DuckHunt", PlayerKilledNPC )

achievements.Register( "Duckhunt", "Kill 200 flying NPCs (manhacks, scanners, birds) with the shotgun.", "achievements/duckhunt", killed / 200, killed .. "/200" )